package com.csy.orm_ktorm.model
import org.ktorm.database.Database
import org.ktorm.entity.Entity
import org.ktorm.entity.sequenceOf
import org.ktorm.schema.*

interface User : Entity<User> {
    companion object : Entity.Factory<User>()

    val id: Long

    val age: Int

    var name: String

    var email: String
}


object Users : Table<User>("user") {

    val id = long("id").primaryKey().bindTo { it.id }

    val name = varchar("name").bindTo { it.name }

    val email = varchar("email").bindTo { it.email }

    val age = int("age").bindTo { it.age }
}

val Database.users get() = this.sequenceOf(Users)
